<template>
  <b-container style="padding: 0" fluid>
    <b-row v-if="$store.state.time.year!=''" class="locationCard mt-3">
      <!-- {{location}}     -->
      <h6>
        {{ $store.state.time.year }}年{{ $store.state.time.month }}月{{
          $store.state.time.day
        }}日 {{ $store.state.time.week }}
        {{ $store.state.time.hour }}:{{ $store.state.time.minute }}:{{
          $store.state.time.second
        }}
      </h6>
    </b-row>
    <b-row v-else class="mt-3 locationCard">
      <h6>你好呀,十里春风不及与你相遇~</h6>
    </b-row>
  </b-container>
</template>

<script>
import axios from "axios";

export default {
  name: "TheLocation",
  data() {
    return {
      location: "正在获取位置...",
    };
  },
  methods: {
    //查询ip地址 https://www.hlapi.cn/api/bjip
    getLocation() {
      axios
        .get("https://tbip.alicdn.com/api/queryip")
        .then((res) => {
          console.log(res);
          this.location = res;
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
  mounted() {
    //需要后端传递地域地址
    //this.getLocation();
  },
};
</script>

<style scoped lang="css">
.locationCard {
  text-align: right;
  padding: 0;
}
</style>